package webcrawler;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class ChinaCity {
    private String name;
    private String code;
    private List<ChinaDistrict> districts = new ArrayList<>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public List<ChinaDistrict> getDistricts() {
        return districts;
    }

    public void setDistricts(List<ChinaDistrict> districts) {
        if(districts == null) throw new RuntimeException("ChinaDistrict list is null");
        this.districts = districts;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ChinaCity chinaCity = (ChinaCity) o;
        return name.equals(chinaCity.name) &&
                code.equals(chinaCity.code);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, code);
    }
}
